package com.example.yunnan.controller;

import com.example.yunnan.pojo.user;
import com.example.yunnan.result.Result;
import com.example.yunnan.service.loginuserservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.HtmlUtils;

@Controller
public class loginusercontroller {
    @Autowired
    loginuserservice loginuserservice;
    @CrossOrigin
    @PostMapping(value = "/api/login")
    @ResponseBody

    public Result login(@RequestBody user requestUser) {
        String username = requestUser.getUsername();
        username = HtmlUtils.htmlEscape(username);
        user user = loginuserservice.get(username, requestUser.getPassword());
        if (null == user) {
            return new Result(400);
        } else {
            return new Result(200);
        }
    }



}

